/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSky;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import ru.jSky.interfaces.Armor;
import ru.jSky.interfaces.Enchantment;
import ru.jSky.interfaces.JSkyMod;
import ru.jSky.interfaces.Keyword;
import ru.jSky.interfaces.Major;
import ru.jSky.bridge.ModBridge;
import skyproc.FormID;
import skyproc.GRUP_TYPE;
import skyproc.Mod;

/**
 *
 * @author Rakev
 */
public class CompositeMod implements JSkyMod {

    private Collection<JSkyMod> mods;

    public CompositeMod(Collection<JSkyMod> mods) {
        this.mods = mods;
    }

    @Override
    public Major makeCopy(Major template, String newEDID) {
        throw new UnsupportedOperationException("Not supported.");
    }

    @Override
    public void addAsOverrides(JSkyMod mod, GRUP_TYPE... grupTypes) {
        throw new UnsupportedOperationException("Not supported.");
    }

    @Override
    public Major getMajor(FormID id, GRUP_TYPE... lookingGrups) {
        for (JSkyMod mod : mods) {
            Major finded = mod.getMajor(id, lookingGrups);
            if (finded != null) {
                return finded;
            }
        }
        return null;
    }

    @Override
    public Major getMajor(String editId, GRUP_TYPE... lookingGrups) {
        for (JSkyMod mod : mods) {
            Major finded = mod.getMajor(editId, lookingGrups);
            if (finded != null) {
                return finded;
            }
        }
        return null;
    }

    @Override
    public boolean contains(FormID form) {
        for (JSkyMod mod : mods) {
            if (mod.contains(form)) {
                return true;
            }
        }
        return false;
    }

    @Override
    public boolean contains(Major major) {
        FormID id = major.getForm();
        return contains(id);
    }

    @Override
    public Collection<Armor> getArmors() {
        Set<Armor> armors = new HashSet<>();
        for (JSkyMod mod : mods) {
            armors.addAll(mod.getArmors());
        }
        return armors;
    }

    @Override
    public Collection<Enchantment> getEnchantments() {
        Set<Enchantment> enchantments = new HashSet<>();
        for (JSkyMod mod : mods) {
            enchantments.addAll(mod.getEnchantments());
        }
        return enchantments;
    }

    @Override
    public Collection<Keyword> getKeywords() {
        Set<Keyword> keywords = new HashSet<>();
        for (JSkyMod mod : mods) {
            keywords.addAll(mod.getKeywords());
        }
        return keywords;
    }
}
